package com.aaa.service.impl;

import com.aaa.dao.ProductDao;
import com.aaa.entity.Product;
import com.aaa.service.ProductService;
import com.aaa.util.DefaultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductDao productDao;
    @Override
    public List<Product> listAll() {
        List<Product> products=productDao.listAll();
        return products;
    }
    @Override
    public DefaultMsg insert(Product product) {
        DefaultMsg defaultMsg=new DefaultMsg();
        Integer insert = productDao.insert(product);
          if (insert==1){
              defaultMsg.setSuccess(0);
              defaultMsg.setError("用户或者密码错误");
          }

        return defaultMsg;
    }
@Override
    public Product findByPid(Product product) {
    Product byPid = productDao.findByPid(product);
    return byPid;
    }
  @Override
    public DefaultMsg update(Product product) {
        DefaultMsg defaultMsg=new DefaultMsg();
        Integer update=productDao.update(product);
        return defaultMsg;

    }
@Override
    public DefaultMsg delete(Product product) {
        DefaultMsg defaultMsg=new DefaultMsg();
    Integer delete = productDao.delete(product);
    return defaultMsg;
}
}
